package com.google.code.mochaccino.framework.xml.stax;
/*
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import javax.xml.namespace.NamespaceContext;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

/**
 * Wrapper over the XMLStreamWriter. This classe serves only to
 * make sure that further implementations down the road aren't
 * polluted with the bases methods that we have no control about.
 */
public abstract class StAXWriterBase implements StAXWriter {

	protected XMLStreamWriter writer = null;

	protected StAXWriterBase( XMLStreamWriter pWriter ) {
		writer = pWriter;
	}

	@Override
	public final void close() throws XMLStreamException {
		writer.close();
	}

	@Override
	public final void flush() throws XMLStreamException {
		writer.flush();
	}

	@Override
	public final NamespaceContext getNamespaceContext() {
		return writer.getNamespaceContext();
	}

	@Override
	public final String getPrefix( String prefix ) throws XMLStreamException {
		return writer.getPrefix( prefix );
	}

	@Override
	public final Object getProperty( String property ) throws IllegalArgumentException {
		return writer.getProperty( property );
	}

	@Override
	public final void setDefaultNamespace( String namespace ) throws XMLStreamException {
		writer.setDefaultNamespace( namespace );
	}

	@Override
	public final void setNamespaceContext( NamespaceContext ctx ) throws XMLStreamException {
		writer.setNamespaceContext( ctx );
	}

	@Override
	public final void setPrefix( String prefix, String url ) throws XMLStreamException {
		writer.setPrefix( prefix, url );
	}

	@Override
	public final void writeAttribute( String name, String value ) throws XMLStreamException {
		if ( value == null ) {
			value = "";
		}
		if ( name != null ) {
			writer.writeAttribute( name, value );
		}
	}

	@Override
	public final void writeAttribute( String namespace, String name, String value ) throws XMLStreamException {
		if ( value == null ) {
			value = "";
		}
		if ( name != null ) {
			writer.writeAttribute( namespace, name, value );
		}
	}

	@Override
	public final void writeAttribute( String prefix, String namespace, String name, String pValue ) throws XMLStreamException {
		if ( pValue == null ) {
			pValue = "";
		}
		if ( name != null ) {
			writer.writeAttribute( prefix, namespace, name, pValue );
		}
	}

	@Override
	public final void writeCData( String pData ) throws XMLStreamException {
		writer.writeCData( pData );
	}

	@Override
	public final void writeCharacters( char[] pValue, int pStartIndex, int pEndIndex ) throws XMLStreamException {
		if ( pValue != null ) {
			writer.writeCharacters( pValue, pStartIndex, pEndIndex );
		}
	}

	@Override
	public final void writeCharacters( String pValue ) throws XMLStreamException {
		if ( pValue != null ) {
			writer.writeCharacters( pValue );
		}
	}

	@Override
	public final void writeComment( String pValue ) throws XMLStreamException {
		if ( pValue != null ) {
			writer.writeComment( pValue );
		}
	}

	@Override
	public final void writeDTD( String pValue ) throws XMLStreamException {
		if ( pValue != null ) {
			writer.writeDTD( pValue );
		}
	}

	@Override
	public final void writeDefaultNamespace( String pValue ) throws XMLStreamException {
		if ( pValue != null ) {
			writer.writeDefaultNamespace( pValue );
		}
	}

	@Override
	public final void writeEmptyElement( String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeEmptyElement( name );
		}
	}

	@Override
	public final void writeEmptyElement( String namespace, String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeEmptyElement( namespace, name );
		}
	}

	@Override
	public final void writeEmptyElement( String prefix, String namespace, String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeEmptyElement( prefix, namespace, name );
		}
	}

	@Override
	public final void writeEndDocument() throws XMLStreamException {
		writer.writeEndDocument();
	}

	@Override
	public final void writeEndElement() throws XMLStreamException {
		writer.writeEndElement();
	}

	@Override
	public final void writeEntityRef( String pEntityRef ) throws XMLStreamException {
		if ( pEntityRef != null ) {
			writer.writeEntityRef( pEntityRef );
		}
	}

	@Override
	public final void writeNamespace( String prefix, String uri ) throws XMLStreamException {
		writer.writeNamespace( prefix, uri );
	}

	@Override
	public final void writeProcessingInstruction( String target ) throws XMLStreamException {
		writer.writeProcessingInstruction( target );
	}

	@Override
	public final void writeProcessingInstruction( String target, String data ) throws XMLStreamException {
		writer.writeProcessingInstruction( target, data );
	}

	@Override
	public final void writeStartDocument() throws XMLStreamException {
		writer.writeStartDocument();
	}

	@Override
	public final void writeStartDocument( String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeStartDocument( name );
		}
	}

	@Override
	public final void writeStartDocument( String namespace, String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeStartDocument( namespace, name );
		}
	}

	@Override
	public final void writeStartElement( String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeStartElement( name );
		}
	}

	@Override
	public final void writeStartElement( String namespace, String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeStartElement( namespace, name );
		}
	}

	@Override
	public final void writeStartElement( String prefix, String namespace, String name ) throws XMLStreamException {
		if ( name != null ) {
			writer.writeStartElement( prefix, namespace, name );
		}
	}
}
